package com.byedu.course;

import com.byedu.domain.course.CourseAnalysisDO;
import com.byedu.domain.course.JobInforDO;
import com.byedu.domain.course.vo.CourseAnalysisVO;
import com.byedu.domain.course.vo.JobInforVO;
import com.byedu.mapper.course.CourseAnalysisMapper;
import com.byedu.mapper.course.JobInforMapper;
import com.byedu.model.enums.CityTypeEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Luo on 2017-09-21.
 */
@Service
public class CourseAnalysisService {

    @Autowired
    CourseAnalysisMapper courseAnalysisMapper;

    public List<CourseAnalysisVO> getCourseAnalysisList(CourseAnalysisDO courseAnalysisDO) {

        return convertDoListToVoList(courseAnalysisMapper.getCourseAnalysisList(courseAnalysisDO));
    }

    public CourseAnalysisDO getCourseAnalysisbyId(int id) {

        return courseAnalysisMapper.getCourseAnalysisbyId(id);
    }
    public List<CourseAnalysisVO> convertDoListToVoList(List<CourseAnalysisDO> courseAnalysisDOList) {
        List<CourseAnalysisVO> courseAnalysisVOlist = new ArrayList<CourseAnalysisVO>();
        if (CollectionUtils.isNotEmpty(courseAnalysisDOList)) {

            for (CourseAnalysisDO courseAnalysisDO : courseAnalysisDOList) {
                CourseAnalysisVO courseAnalysisVO = new CourseAnalysisVO(courseAnalysisDO);
                courseAnalysisVOlist.add(courseAnalysisVO);
            }

            return courseAnalysisVOlist;
        }
        return courseAnalysisVOlist;
    }

    public List<CourseAnalysisVO> getCourseAnalysisLists() {

        return convertDoListToVoList(courseAnalysisMapper.getCourseAnalysisLists());
    }

    public int saveCourseAnalysis(CourseAnalysisDO courseAnalysisDO){
        return courseAnalysisMapper.saveCourseAnalysis(courseAnalysisDO);
    }

    public int updateCourseAnalysis(CourseAnalysisDO courseAnalysisDO){
        return courseAnalysisMapper.updateCourseAnalysis(courseAnalysisDO);
    }
}
